<?php
/**
 * 获取创瑞网短信数据api
 * User: Wong
 * Date: 17-04-28
 * Time: 下午2:10
 */
namespace utils\sms;

class GetCr6868Info
{
    private $user = null;
    private $pass = null;

    public function set($user, $pass){
        $this->user = $user;
        $this->pass = $pass;
    }

    /**
     * 查询用户短信剩余数量
     */

    public function getInfo(){
        $url = 'http://web.cr6868.com/asmx/smsservice.aspx?name=' . $this->user . '&pwd=' . $this->pass .'&type=balance';
        $ch = curl_init();
        $timeout = 5;
        curl_setopt ($ch, CURLOPT_URL, $url);
        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
        $file_contents = curl_exec($ch);
        curl_close($ch);
        $info = explode(',',$file_contents);
        switch($info[0]){
            case 0:
                return array('balance'=>$info[1],'message'=>'success','code'=>$info[0]);break;
            default :
                return array('balance'=>0,'message'=>$info[1],'code'=>$info[0]);break;
        }
    }
}

?>